﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="XmlRuleSet"
    targetNamespace="http://codeplex.com/colonization/xmlruleset.xsd"
    elementFormDefault="qualified"
    xmlns="http://codeplex.com/colonization/xmlruleset.xsd"
    xmlns:mstns="http://codeplex.com/colonization/xmlruleset.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
  <xs:element name="RuleSet" type="RuleSet" />
  <xs:complexType name="RuleSet">
    <xs:sequence maxOccurs="1" minOccurs="1">
      <xs:element name="Images" type="ArrayOfImageType" />
      <xs:element name="TerrainTypes" type="ArrayOfTerrainType" />
      <xs:element name="TileTypes" type="TileTypes" />
      <xs:element name="RawMaterialTypes" type="ArrayOfRawMaterialType" />
      <xs:element name="BonusResourceTypes" type="ArrayOfBonusResourceType" />
      <xs:element name="UnitTypes" type="ArrayOfUnitType" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="ArrayOfImageType">
    <xs:sequence maxOccurs="unbounded" minOccurs="0">
      <xs:element name="Image" type="ImageType" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="ImageType">
    <xs:sequence maxOccurs="1" minOccurs="1">
      <xs:element name="Id" type="xs:ID" nillable="false" />
      <xs:element name="Path" type="xs:string" nillable="false" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="ArrayOfTerrainType">
    <xs:sequence maxOccurs="unbounded" minOccurs="0">
      <xs:element name="TerrainType" type="TerrainType" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="TileTypes">
    <xs:sequence maxOccurs="1" minOccurs="1">
      <xs:element name="TileTypeRef">
        <xs:complexType>
          <xs:attribute name="idref" use="required" type="xs:IDREF" />
        </xs:complexType>
      </xs:element>
      <xs:element name="Types">
        <xs:complexType>
          <xs:sequence minOccurs="0" maxOccurs="unbounded">
            <xs:element name="TileType" type="TileType" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="ArrayOfRawMaterialType">
    <xs:sequence maxOccurs="unbounded" minOccurs="0">
      <xs:element name="RawMaterialType" type="RawMaterialType" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="ArrayOfImageRef">
    <xs:sequence maxOccurs="unbounded" minOccurs="1">
      <xs:element name="ImageRef">
        <xs:complexType>
          <xs:attribute name="idref" use="required" type="xs:IDREF" />
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="ArrayOfBonusResourceType">
    <xs:sequence maxOccurs="unbounded" minOccurs="0">
      <xs:element name="BonusResourceType" type="BonusResourceType" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="ArrayOfUnitType">
    <xs:sequence minOccurs="0" maxOccurs="unbounded">
      <xs:element name="UnitType" type="UnitType" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="TileType">
    <xs:sequence minOccurs="1" maxOccurs="1">
      <xs:element name="Id" type="xs:ID" nillable="0" />
      <xs:element name="NameCode" type="xs:string" nillable="0" />
      <xs:element name="DescriptionCode" type="xs:string" nillable="0" />
      <xs:element name="TerrainTypeRef" nillable="0">
        <xs:complexType>
          <xs:attribute name="idref" type="xs:IDREF" use="required" />
        </xs:complexType>        
      </xs:element>
      <xs:element name="MoveCost" type="xs:nonNegativeInteger" nillable="0" />
      <xs:element name="DefenseBonus" type="xs:nonNegativeInteger" nillable="0" />
      <xs:element name="BonusResourceTypeRef" minOccurs="0" maxOccurs="1">
        <xs:complexType>
          <xs:attribute name="idref" type="xs:IDREF" use="required" />
        </xs:complexType>
      </xs:element>
      <xs:element name="TileProductions" type="ArrayOfTileProduction" nillable="0" />
      <xs:element name="Images" nillable="false" minOccurs="1" maxOccurs="1" type="ArrayOfImageRef" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="ArrayOfTileProduction">
    <xs:sequence maxOccurs="unbounded" minOccurs="0">
      <xs:element name="TileProduction" type="TileProduction" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="TileProduction">
    <xs:sequence maxOccurs="1" minOccurs="1">
      <xs:element name="RawMaterialTypeRef" minOccurs="1" maxOccurs="1">
        <xs:complexType>
          <xs:attribute name="idref" type="xs:IDREF" use="required" />
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="Base" type="xs:nonNegativeInteger" use="required" />
    <xs:attribute name="PlowBonus" type="xs:nonNegativeInteger" use="required" />
    <xs:attribute name="RoadBonus" type="xs:nonNegativeInteger" use="required" />
    <xs:attribute name="RiverBonus" type="xs:nonNegativeInteger" use="required" />
    <xs:attribute name="ExpertBonus" type="xs:nonNegativeInteger" use="required" />
    <xs:attribute name="ExpertBonusType" use="required">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:enumeration value="Add" />
          <xs:enumeration value="Multiply" />
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="RawMaterialType">
    <xs:sequence maxOccurs="1" minOccurs="1">
      <xs:element name="Id" type="xs:ID" nillable="0"/>
      <xs:element name="NameCode" type="xs:string" nillable="0" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="BonusResourceType">
    <xs:sequence maxOccurs="1" minOccurs="1">
      <xs:element name="Id" type="xs:ID" nillable="0"/>
      <xs:element name="NameCode" type="xs:string" nillable="0" />
      <xs:element name="BonusTypes" type="ArrayOfBonusType" nillable="0" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="ArrayOfBonusType">
    <xs:sequence minOccurs="0" maxOccurs="unbounded">
      <xs:element name="BonusType" type="BonusType" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="BonusType">
    <xs:sequence minOccurs="1" maxOccurs="1">
      <xs:element name="RawMaterialTypeRef" nillable="0">
        <xs:complexType>
          <xs:attribute name="idref" type="xs:IDREF" use="required" />
        </xs:complexType>
      </xs:element>
      <xs:element name="AccesibleBonus" type="xs:nonNegativeInteger" />
      <xs:element name="Bonus" type="xs:nonNegativeInteger" />
      <xs:element name="BonusOperationType">
        <xs:simpleType>
          <xs:restriction base="xs:string">
            <xs:enumeration value="Add" />
            <xs:enumeration value="Multiply" />
          </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="TerrainType">
    <xs:sequence minOccurs="1" maxOccurs="1">
      <xs:element name="Id" type="xs:ID" nillable="0" />
      <xs:element name="Code" type="xs:string" nillable="0" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="UnitType">
    <xs:sequence minOccurs="1" maxOccurs="1">
      <xs:element name="Id" type="xs:ID" nillable="0" />
      <xs:element name="CargoSlots" type="xs:nonNegativeInteger" nillable="0" />
      <xs:element name="BaseAttackStrength" type="xs:nonNegativeInteger" nillable="0" />
      <xs:element name="IsCombatUnit" type="xs:boolean" nillable="0" />
      <xs:element name="TerrainTypeRef" nillable="0">
        <xs:complexType>
          <xs:attribute name="idref"  type="xs:IDREF" use="required" />
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:schema>
